package arithmetic.functionTest.myStream;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * 简化版stream实现
 * (没有int long,double 装拆箱优化,没有并行流)
 * @author jiangfeng 2020/4/26 10:28
 */
public interface MyStream<T> {

    /**
     * 静态构造方法
     */
    static <T>  MyStream<T>  of(Collection<? extends T> items) {
        return new MyReferencePipeline.Head<>(items.iterator());
    }

    @SafeVarargs
    static <T> MyStream<T> of(T... items) {
        return new MyReferencePipeline.Head<>(Arrays.asList(items).iterator());
    }

    // map方法
    <R> MyStream<R> map(Function<? super T, ? extends R> fun);

   // MyStream<T> sort(Comparator<T> comparator);

    // foreach
    void foreach(Consumer<T> consumer);


   // Optional<T> min(Comparator<T> comparator);

    //Optional<T> max(Comparator<T> comparator);



}
